<template>
  <div class="starry-sky">
    <div v-for="i in 5" :key="i" :class="'layer' + i"></div>
  </div>
</template>

<style scoped lang="scss">
@use 'sass:math';
@use 'sass:string';

.starry-sky {
  width: 100%;
  height: 100%;
  background-color: var(--color-black);
}

@function star($n) {
  $result: '#{math.random(100)}vw #{math.random(100)}vh #fff';

  @for $i from 2 through $n {
    $result: '#{$result} , #{math.random(100)}vw #{math.random(100)}vh #fff';
  }

  @return string.unquote($result);
}



$n: 5;
$duration: 400s;
$count : 1000;

@for $i from 1 through $n {
  $duration: math.floor(calc($duration / 2));
  $count: math.floor(calc($count / 2));

  .layer#{$i} {
    width: #{$i*2}px;
    height: #{$i*2}px;
    left: 0;
    top: 0;
    border-radius: 50%;
    background: rgb(255, 255, 255);
    box-shadow: star($count);
    animation: move $duration linear infinite;
  }

  .layer#{$i}::after {
    content: '';
    position: absolute;
    width: inherit;
    height: inherit;
    border-radius: inherit;
    box-shadow: inherit;
    left: 0;
    top: 100vh;

  }

}

@keyframes move {
  to {
    transform: translateY(-100vh);
  }
}
</style>
